package Shape;

public class Circle {
    //定义成员变量-->
    final double PI = 3.14;
    private double r;
    public double getR(){
        return r;
    }
    public double setR(double r){
        if(r<0){
            System.out.println("半径不能为负数");
        }else{
            this.r = r;
        }
        return r;

    }
    //方法 getArea()-->圆的面积
    public Circle(){

    }
    public Circle(double r){
        this.r=r;
        getArea();
        getPerimeter();
    }
    public void getArea() {
        double S;
        S = PI * r * r;
        System.out.println("半径是"+r+"圆的面积为："+S);
    }
    //方法 getPerimeter()-->圆的周长
    public void getPerimeter(){
        double C;
        C = 2 * PI * r;
        System.out.println("半径是"+r+"圆的周长为："+C);

    }
}
